package stark.app.function.more;

import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hjq.bar.OnTitleBarListener;
import com.stark.more.MoreInfoActivity;
import com.stark.more.entity.FriendShareMoreItem;
import com.stark.more.entity.MoreItem;
import com.stark.more.entity.PraiseMoreItem;
import com.stark.more.entity.UrlMoreItem;

import java.util.ArrayList;
import java.util.List;

import stark.app.R;
import stark.app.databinding.ActivitySubMoreInfoBinding;
import stark.common.basic.base.BaseWebviewActivity;

/**
 * Author：daizhongbin on 2021/3/30
 * Email：1027154338@qq.com
 * Desc:
 */
public class SubMoreInfoActivity extends MoreInfoActivity<ActivitySubMoreInfoBinding> {
    @Override
    protected RecyclerView getRvView() {
        return mDataBinding.rvItems;
    }

    @Override
    protected RecyclerView.LayoutManager getLayoutManager() {
        final int SPAN_COUNT = 3;
        GridLayoutManager layoutManager = new GridLayoutManager(this, SPAN_COUNT) {
            @Override
            public RecyclerView.LayoutParams generateDefaultLayoutParams() {
                return new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT);
            }
        };
        return layoutManager;
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_sub_more_info;
    }

    @Override
    protected List<MoreItem> getMoreItems() {
        return loadItems();
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_sub_more_info;
    }

    @Override
    protected void initView() {
        //titlebar
        mDataBinding.tbTitle.setOnTitleBarListener(new OnTitleBarListener() {
            @Override
            public void onLeftClick(View view) {
                onBackPressed();
            }

            @Override
            public void onTitleClick(View view) {
            }

            @Override
            public void onRightClick(View view) {
            }
        });
    }

    @Override
    protected void initData() {
    }

    private List<MoreItem> loadItems() {
        List<MoreItem> itemList = new ArrayList<>();
        MoreItem item = null;

        int rightImgId = -1;

        final String URL = "https://www.baidu.com";
        //隐私策略
        item = new UrlMoreItem(getString(com.stark.more.R.string.more_privacy), com.stark.more.R.drawable.ic_more_privacy,
                rightImgId, URL, getString(com.stark.more.R.string.more_privacy));
        itemList.add(item);

        //使用条款
        item = new UrlMoreItem(getString(com.stark.more.R.string.more_term_use), com.stark.more.R.drawable.ic_more_agreement,
                rightImgId, URL, getString(com.stark.more.R.string.more_term_use));
        itemList.add(item);

        //意见反馈
        item = new UrlMoreItem(getString(com.stark.more.R.string.more_feedback), com.stark.more.R.drawable.ic_more_feedback,
                rightImgId, BaseWebviewActivity.getFeedbackUrl(this), getString(com.stark.more.R.string.more_feedback));
        itemList.add(item);

        //好评鼓励
        item = new PraiseMoreItem(getString(com.stark.more.R.string.more_praise_encouragement), com.stark.more.R.drawable.ic_more_high_praise,
                rightImgId);
        itemList.add(item);

        //好友分享
        item = new FriendShareMoreItem(getString(com.stark.more.R.string.more_friend_share), com.stark.more.R.drawable.ic_more_share,
                rightImgId);
        itemList.add(item);

        //其它根据自己业务需求来设计的条目
        item = new OtherMoreItem("其它自定义条目", com.stark.more.R.drawable.ic_more_high_praise, rightImgId);
        itemList.add(item);

        return itemList;
    }
}
